import http from '@/api'
import { ADMIN_MODULE } from '@/api/helper/prefix'
import type { IPage } from '@/api/types';
import type {ChararterTagQuery, ChararterTagRow, ChararterTagForm, TagRelate} from '@/api/types/novel/chararterTag'
import type { UploadRawFile } from "element-plus/es/components/upload/src/upload";
import type { AxiosRequestConfig } from 'axios';

/**
* 查询列表
* @param params
* @returns {*}
*/
export const getChararterTagListApi = (params: ChararterTagQuery) => {
  return http.get<IPage<ChararterTagRow>>(ADMIN_MODULE + `/chararter-tag`, params)
}

/**
* 查询详情模式的列表
* @param params
* @returns {*}
*/
export const getDetailModeTagListApi = (params: {busId: number | any}) => {
  return http.get<IPage<ChararterTagRow>>(ADMIN_MODULE + `/chararter-tag/detailMode`, params)
}

/**
* 批量保存标签
* @param params
* @returns {*}
*/
export const batchSaveRelative = (params: TagRelate[]) => {
  return http.post(ADMIN_MODULE + `/chararter-tag/batchSaveRelative`, params)
}


/**
* 添加
* @param params
* @returns {*}
*/
export const createChararterTagApi = (params: ChararterTagForm) => {
  return http.post(ADMIN_MODULE + `/chararter-tag`, params)
}

/**
* 修改
* @param params
* @returns {*}
*/
export const updateChararterTagApi = (params: ChararterTagForm) => {
  return http.put(ADMIN_MODULE + `/chararter-tag`, params)
}

/**
* 删除
* @param params
* @returns {*}
*/
export const removeChararterTagApi = (params: { ids: (string | number)[] }) => {
 return http.delete(ADMIN_MODULE + `/chararter-tag`, params)
}

/**
* 获取详情
* @param params
* @returns {*}
*/
export const getChararterTagDetailApi = (params: { id: number }) => {
  const { id } = params
  return http.get<ChararterTagRow>(ADMIN_MODULE + `/chararter-tag/${id}`)
}

/**
* 导入excel
* @param params
*/
export const importChararterTagExcelApi = (params : UploadRawFile, config?: AxiosRequestConfig<any> | undefined) => {
  return http.upload(ADMIN_MODULE + `/chararter-tag/import`, params, config)
}

/**
* 导出excel
* @param params
* @returns {*}
*/
export const exportChararterTagExcelApi  = (params: ChararterTagQuery) => {
  return http.download(ADMIN_MODULE + `/chararter-tag/export`, params)
}

/**
 * 远程搜索
 * @param params
 */
export const remoteTagApi = (params: { keyword: string }) => {
  const { keyword } = params;
  return http.get<string[]>(ADMIN_MODULE + `/chararter-tag/remote/${keyword}`);
};
